package com.yum.lang;

import java.io.Serializable;

/**
 * Created on 2023/5/25
 *
 * @Time 11:16
 * @Program YunMap
 * @Author YoHaNe/XiaoShuai
 */
public class YCharacter implements Serializable,Comparable<YCharacter> {

    private static final long serialVersionUID = -6353382933642569266L;

    public static final int MIN_RADIX = 2;

    public static final int MAX_RADIX = 36;

    public static final char MIN_VALUE = '\u0000';

    public static final char MAX_VALUE = '\uFFFF';

    private final char value;

    private static class YCharacterCache{
        private YCharacterCache(){}
        static final YCharacter[] cache = new YCharacter[127+1];
        static {
            for(int i = 0;i<cache.length;i++){
                cache[i] = new YCharacter((char) i);
            }
        }
    }

    public YCharacter(char value) {
        this.value = value;
    }

    public static YCharacter valueOf(char val){
        if(val <= 127)
            return YCharacterCache.cache[(int)val];
        return new YCharacter(val);
    }

    public char getValue(){
        return value;
    }

    @Override
    public int hashCode() {
        return hashCode(value);
    }

    public static int hashCode(char value){
        return value;
    }

    @Override
    public int compareTo(YCharacter o) {
        return 0;
    }


}
